<template>
  <div>
    <el-card header="学生获奖情况">
      <div id="studentAwardChart" style="height: 385px; padding-left: 50px; padding-top: 1px;"></div>
    </el-card>
    
    <el-dialog 
      title="学生获奖详情" 
      :visible.sync="awardDialogVisible"
      width="70%"
      @closed="currentAwardStudents = []">
      <el-table 
        :data="currentAwardStudents"
        stripe
        border
        style="width: 100%">
        <!-- 表格列定义 -->
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import * as echarts from 'echarts'

export default {
  name: 'StudentAwardChart',
  props: {
    awardData: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      awardDialogVisible: false,
      currentAwardStudents: [],
      chart: null
    }
  },
  methods: {
    initChart() {
      this.chart = echarts.init(document.getElementById('studentAwardChart'))
      
      const option = {
        // 图表配置选项
      }
      
      this.chart.setOption(option)
      
      // 点击事件处理
      this.chart.on('click', params => {
        const grade = params.name
        const year = params.seriesName
        this.currentAwardStudents = this.awardData[grade]?.[year] || []
        
        if (this.currentAwardStudents.length > 0) {
          this.awardDialogVisible = true
        } else {
          this.$message.info('该学年没有获奖记录')
        }
      })
    },
    resizeChart() {
      if (this.chart) {
        this.chart.resize()
      }
    }
  },
  mounted() {
    this.initChart()
    window.addEventListener('resize', this.resizeChart)
  },
  beforeDestroy() {
    if (this.chart) {
      this.chart.dispose()
    }
    window.removeEventListener('resize', this.resizeChart)
  }
}
</script>